var attachIndex=1;
function showTypeDialog(flag){
	var rand=Math.random()*100000;
	var url=contextPath+'xtreecheckbox/selectProductSort.jsp?type=radio&sortType=1&date='+rand;
	if(flag==2){
		url=contextPath+'xtreecheckbox/selectProductSort.jsp?type=radio&sortType=2&date='+rand;
	}
	var returnData=window.showModalDialog(url,window,"status:no;dialogWidth:450px;dialogHeight:600px;scroll:yes;");
	if(returnData){
		$('#sortName'+flag).val(returnData[1]);
		$('#sortId'+flag).val(returnData[0]);
	}
}

function selectDict(){
    var url=contextPath+'business/productDict/listProductDictSelect.action';
	window.showModalDialog(url, window,"status:no;dialogWidth:800px;dialogHeight:550px;scroll:yes;");
	f_iframeResize();
	window.parent.changeScroll();
}

function selectProcMainPerson(){
	var rand=Math.random()*100000;
    var url=contextPath+'organ/toOrganTree.action?type=&path=toPersonTree&module=radio&date='+rand;
    var returnData=window.showModalDialog(url,window,"status:no;dialogWidth:650px;dialogHeight:600px;scroll:yes;");
	 if(returnData){
	 	document.forms[0]["mainPersonNames"].value=returnData[1];
	 	document.forms[0]["mainPersons"].value=returnData[0];
	 }
}
function selectProPerson(){
	var rand=Math.random()*100000;
    var url=contextPath+'organ/toOrganTree.action?type=&path=toPersonTree&module=checkbox&date='+rand;
	 var returnData=window.showModalDialog(url,window,"status:no;dialogWidth:650px;dialogHeight:600px;scroll:yes;");
	 if(returnData){
	 	document.forms[0]["personNames"].value=returnData[1];
	 	document.forms[0]["persons"].value=returnData[0];
	 }
}

$(document).ready(function(){
	$('.addBtnCss').click(function(){
		var p=$(this).parent();
		var p2=$(p).parent();
		var fileName=$('input',p).attr('name')+'-'+attachIndex;
		var fileHtml='<div><input class="uploadFileCss" type="file" name="'+fileName+'" style="width: 80%"/><button class="delBtnClass" type="button" style="margin-right: 6px">删除</button></div>';
		$(p2).append(fileHtml);
		attachIndex++;
		f_iframeResize();
	});
	
	$('.delBtnClass').live('click',function(){
		$(this).parent().remove();
		f_iframeResize();
	});
	
	$('#isClientSel').change(function(){
		var value=$(this).val();
		if(value=='1'){
			$('input[type="file"]').each(function(){
					var name=$(this).attr('name');
					if(name.indexOf('productClient')!=-1){
						$(this).attr('dataType','Require');
						$(this).attr('msg','*');
					}
			});
		}else{
			$('input[type="file"]').each(function(){
				var name=$(this).attr('name');
				if(name.indexOf('productClient')!=-1){
					$(this).removeAttr('dataType','Require');
					$(this).removeAttr('msg','*');
				}
			});
		}
	});
	
	
});